package control
{
	import model.ModelLocator;
	import flash.events.Event;
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	
	import view.Markers;
	public class ShowAllMyMarker
	{
		internal var theModel:ModelLocator = ModelLocator.getInstance();
		private var ShowAllMyMarkerRO:RemoteObject;
		public var mark:view.Markers;
		public function ShowAllMyMarker()
		{
			this.mark = mark;
			ShowAllMyMarkerRO = new RemoteObject();
			ShowAllMyMarkerRO.destination="ShowAllMyMarker";
			ShowAllMyMarkerRO.doShowAllMyMarker.addEventListener(ResultEvent.RESULT,ShowAllMyMarkerResultHandler);
			ShowAllMyMarkerRO.addEventListener(FaultEvent.FAULT, ShowAllMyMarkerFaultHandler);
		}
		
		public function doShowAllMyMarker():void
		{
			ShowAllMyMarkerRO.doShowAllMyMarker(theModel.user.user_id);
		}
		
		internal function ShowAllMyMarkerResultHandler(event:ResultEvent):void
		{
				Alert.show("show all markers Successfully.");
				theModel.allTheTypeMarkers = event.result as ArrayCollection;
				//Alert.show(theModel.allShowAllMyMarker[1]['username']);
				theModel.dispatchEvent(new Event(ModelLocator.SHOWTYPEMARKERS_OK));
		}
		
		internal function ShowAllMyMarkerFaultHandler(event:FaultEvent):void
		{
			Alert.show("error occur when show all your markers");
		}
	}
}